bitkeeper revision 1.1159.1.24 (4117b6a1euBrYZVVvGdpODhTzq8iNA)
authoriap10@labyrinth.cl.cam.ac.uk <iap10@labyrinth.cl.cam.ac.uk>
Mon, 9 Aug 2004 17:38:41 +0000 (17:38 +0000)
committeriap10@labyrinth.cl.cam.ac.uk <iap10@labyrinth.cl.cam.ac.uk>
Mon, 9 Aug 2004 17:38:41 +0000 (17:38 +0000)
Fix migrate to cope with domains that are paused.

tools/libxc/xc_linux_save.c

index 5a3edb2bd830c174c18cd5dba721de9349dac9d4..26abf632ae981bc443aac0bdfa2c0e647d4d9c40 100644 (file)
@@ -240,6 +240,55 @@ static int analysis_phase( int xc_handle, u32 domid,
     return -1;
 }
 
+
+int suspend_and_state( int xc_handle, XcIOContext *ioctxt,                   
+                      dom0_op_t *op,
+                      full_execution_context_t *ctxt )
+{
+    int i=0;
+    
+    xcio_suspend_domain(ioctxt);
+
+retry:
+
+    if ( xc_domain_getfullinfo( xc_handle, ioctxt->domain, op, ctxt) )
+    {
+       xcio_error(ioctxt, "Could not get full domain info");
+       return -1;
+    }
+
+    if ( (op->u.getdomaininfo.flags & 
+         ( DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT) ))
+        == ( DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT) ))
+    {
+       return 0; // success
+    }
+
+    if ( op->u.getdomaininfo.flags & DOMFLAGS_PAUSED )
+    {
+       // try unpausing domain, wait, and retest       
+       xc_domain_unpause( xc_handle, ioctxt->domain );
+
+       xcio_error(ioctxt, "Domain was paused. Wait and re-test. (%lx)",
+                  op->u.getdomaininfo.flags);
+       usleep(10000);  // 10ms
+
+       goto retry;
+    }
+
+
+    if( ++i < 3 )
+    {
+       usleep(10000);  // 10ms 
+       goto retry;
+    }
+
+    xcio_error(ioctxt, "Unable to suspend domain. (%lx)",
+              op->u.getdomaininfo.flags);
+
+    return -1;
+}
+
 int xc_linux_save(int xc_handle, XcIOContext *ioctxt)
 {
     dom0_op_t op;
@@ -407,23 +456,17 @@ int xc_linux_save(int xc_handle, XcIOContext *ioctxt)
 
         last_iter = 1;
 
-       xcio_suspend_domain(ioctxt);
-
-       if ( xc_domain_getfullinfo( xc_handle, domid, &op, &ctxt) )
-       {
-           xcio_error(ioctxt, "Could not get full domain info");
-           goto out;
-       }
-
-       if ( (op.u.getdomaininfo.flags & 
-            ( DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT) ))
-            != ( DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT) ))
+       if ( suspend_and_state( xc_handle, ioctxt, &op, &ctxt) )
        {
            xcio_error(ioctxt, "Domain appears not to have suspended: %lx",
                       op.u.getdomaininfo.flags);
            goto out;
        }
 
+       printf("SUSPPPPPPPP flags %08lx shinfo %08lx eip %08lx esi %08lx\n", 
+              op.u.getdomaininfo.flags, op.u.getdomaininfo.shared_info_frame,
+              ctxt.cpu_ctxt.eip, ctxt.cpu_ctxt.esi );
+
     }
 
     /* calculate the power of 2 order of nr_pfns, e.g.
@@ -779,26 +822,18 @@ int xc_linux_save(int xc_handle, XcIOContext *ioctxt)
                 DPRINTF("Start last iteration\n");
                 last_iter = 1;
 
-               xcio_suspend_domain(ioctxt);
-               
-               if ( xc_domain_getfullinfo( xc_handle, domid, &op, &ctxt) )
-               {
-                   xcio_error(ioctxt, "Could not get full domain info");
-                   goto out;
-               }
-               
-               if ( (op.u.getdomaininfo.flags & 
-                     ( DOMFLAGS_SHUTDOWN |
-                       (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT) ))
-                    != ( DOMFLAGS_SHUTDOWN |
-                         (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT) ))
+               if ( suspend_and_state( xc_handle, ioctxt, &op, &ctxt) )
                {
-                   xcio_error(ioctxt, 
-                              "Domain appears not to have suspended: %lx",
+                   xcio_error(ioctxt, "Domain appears not to have suspended: %lx",
                               op.u.getdomaininfo.flags);
                    goto out;
                }
 
+               printf("SUSPPPPPPPP flags %08lx shinfo %08lx eip %08lx esi %08lx\n", 
+                      op.u.getdomaininfo.flags, op.u.getdomaininfo.shared_info_frame,
+                      ctxt.cpu_ctxt.eip, ctxt.cpu_ctxt.esi );
+
+
             } 
 
             if ( xc_shadow_control( xc_handle, domid,